﻿@*@model IEnumerable<NK.Mvc3.Models.ProductInfo>*@
           
@model PagedList.IPagedList<NK.Mvc3.Models.ProductInfo>

@{
    ViewBag.Title = "Product Info Master List";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create") ||  @Html.ActionLink("Import", "Import")
</p>
@using (Html.BeginForm())
{
    <p>
        Find by name: @Html.TextBox("SearchString", ViewBag.CurrentFilter as string)  
        <input type="submit" value="Search" /></p>
}
<p>
    Total: @ViewBag.ProductNumber
</p>



<div>
    Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    of @Model.PageCount
     
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("<<", "Index", new { page = 1, sortOrder = ViewBag.CurrentSort, currentFilter=ViewBag.CurrentFilter  })
        @Html.Raw(" ");
        @Html.ActionLink("< Prev", "Index", new { page = Model.PageNumber - 1, sortOrder = ViewBag.CurrentSort, currentFilter=ViewBag.CurrentFilter  })
    }
    else
    {
        @:<<
        @Html.Raw(" ");
        @:< Prev
    }
     
    @if (Model.HasNextPage)
    {
        @Html.ActionLink("Next >", "Index", new { page = Model.PageNumber + 1, sortOrder = ViewBag.CurrentSort, currentFilter=ViewBag.CurrentFilter  })
        @Html.Raw(" ");
        @Html.ActionLink(">>", "Index", new { page = Model.PageCount, sortOrder = ViewBag.CurrentSort, currentFilter=ViewBag.CurrentFilter  })
    }
    else
    {
        @:Next >
        @Html.Raw(" ")
        @:>>
    }
</div>


<table>
    <tr>
        <th>
            @Html.ActionLink("Group", "Index", new { sortOrder = ViewBag.GroupSortParm, currentFilter = ViewBag.CurrentFilter })
        </th>
        <th>
            @Html.ActionLink("BarCode", "Index", new { sortOrder = ViewBag.BarCodeSortParm, currentFilter = ViewBag.CurrentFilter })
        </th>
        <th>
            @Html.ActionLink("POSDescription", "Index", new { sortOrder = ViewBag.POSDescriptionSortParm, currentFilter = ViewBag.CurrentFilter })
            
        </th>
        <th>
            @Html.ActionLink("ProductName", "Index", new { sortOrder = ViewBag.ProductNameSortParm, currentFilter = ViewBag.CurrentFilter })
        </th>
        <th>
            PKT
        </th>
        <th>
            Package
        </th>
        <th>
            @Html.ActionLink("Cost", "Index", new { sortOrder = ViewBag.CostSortParm, currentFilter = ViewBag.CurrentFilter })
        </th>
        <th>
            VAT
        </th>
        <th>
            Cost&VAT
        </th>
        <th>
            PriceA
        </th>
        <th>
            PriceB
        </th>
        <th>
            PriceC
        </th>
        <th>
            PriceD
        </th>
        <th>
            @*@Html.ActionLink("Stock", "Index", new { sortOrder = ViewBag.StockSortParm, currentFilter = ViewBag.CurrentFilter })*@
            Stock
        </th>
        <th width="100"></th>
    </tr>

@foreach (var item in Model) {
    <tr >
        <td>
            @Html.DisplayFor(modelItem => item.Group)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.BarCode)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.POSDescription)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ProductName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PKT)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Package)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Cost)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.VAT)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CostIncludeVAT)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PriceA)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PriceB)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PriceC)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.PriceD)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Statistics.Total)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ID })
            @*@Html.ActionLink("Delete", "Delete", new { id=item.ID })*@
        </td>
    </tr>
}

</table>


<div>
    Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    of @Model.PageCount
     
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("<<", "Index", new { page = 1, sortOrder = ViewBag.CurrentSort, currentFilter=ViewBag.CurrentFilter  })
        @Html.Raw(" ");
        @Html.ActionLink("< Prev", "Index", new { page = Model.PageNumber - 1, sortOrder = ViewBag.CurrentSort, currentFilter=ViewBag.CurrentFilter  })
    }
    else
    {
        @:<<
        @Html.Raw(" ");
        @:< Prev
    }
     
    @if (Model.HasNextPage)
    {
        @Html.ActionLink("Next >", "Index", new { page = Model.PageNumber + 1, sortOrder = ViewBag.CurrentSort, currentFilter=ViewBag.CurrentFilter  })
        @Html.Raw(" ");
        @Html.ActionLink(">>", "Index", new { page = Model.PageCount, sortOrder = ViewBag.CurrentSort, currentFilter=ViewBag.CurrentFilter  })
    }
    else
    {
        @:Next >
        @Html.Raw(" ")
        @:>>
    }
</div>